package cn.yunhe.test;

import cn.yunhe.model.User;
import cn.yunhe.service.IUserService;
import cn.yunhe.service.impl.UserServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @描述
 * @参数 $params$
 * @返回值 $return$
 * @创建人 lihui
 * @创建时间 $date$
 * @修改人和其它信息
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/spring-mybatis.xml"})
public class test {
    @Resource(name = "userService")
    private IUserService userService;
    @Test
    public void test1() {
        PageHelper.startPage(1,5);
        List<User> list = userService.findalluser();

        for (User u : list) {
            System.out.println(u.getName());
        }
    }

    @Test
    public void test2(){
        Map<String,Object> user = new HashMap<String,Object>();
        User us = new User();
        us.setName("");
        user.put("user",us);
        PageHelper.startPage(1,5);
        List<User> list = userService.getLikeUsers(user);
        int count = userService.getLikeUsersCount(user);
        Page page = new Page();
        page.setPageSize(5);
        page.setTotal(count);
        System.out.println(page.getPages());
        System.out.println(count);
        for (User u : list) {
            System.out.println(u.getName());//    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=A4749739227af1618f7b0d1b588c0e85"></script>

        }
    }


    public IUserService getUserService() {
        return userService;
    }

    public void setUserService(IUserService userService) {
        this.userService = userService;
    }

}
